package com.list.arraylist;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class IterateArrayList2 {
public static void main(String[] args) {
	List<String> list=new ArrayList<>();
	list.add("deepak");
	list.add("kamal");
	list.add("raj");
	list.add("kunal");
	System.out.println(list);
	for(int i=0;i<list.size();i++){
		String name=list.get(i);
		System.out.println(name);
	}
	
	Iterator<String> iterator=list.iterator();
	while(iterator.hasNext()){
		System.out.println(iterator.next());
		iterator.remove();
	}
	System.out.println(list.size());
}
}
